package models

import (
	"fmt"
	"time"

	"gorm.io/gorm"
)

// UserBasic 用户信息
type UserBasic struct {
	gorm.Model
	Name          string
	Password      string
	Phone         string `valid:"matches(^1[1-9]{1}\\d{9})"`
	Email         string `valid:"email"`
	Identity      string
	ClientIP      string
	ClientPort    string
	LoginTime     time.Time
	HeartbeatTime time.Time
	LogoutTime    time.Time
	IsLogout      bool
	DeviceInfo    string
	Slat          string
}

// TableName 表名
func (*UserBasic) TableName() string {
	return "user_basic"
}

func (u *UserBasic) String() string {
	// `created_at`,`updated_at`,`deleted_at`,`name`,`password`,`phone`,`email`,`identity`,`client_ip`,`client_port`,`login_time`,`heartbeat_time`,`logout_time`,`is_logout`,`device_info`
	return fmt.Sprintf("UserBasic{CreateAt= %v, UpdateAt=%v, DeleteAt=%v, ID=%d, Name=%s, Password=%s, Phone=%s, Email=%s, Identity=%s, ClientIP=%s, ClientPort=%s, LoginTime=%s, HeartbeatTime=%s, LogoutTime=%s, IsLogout=%v, DeviceInfo=%s}",
		u.CreatedAt, u.UpdatedAt, u.DeletedAt, u.ID, u.Name, u.Password, u.Phone, u.Email, u.Identity, u.ClientIP, u.ClientPort, u.LoginTime, u.HeartbeatTime, u.LogoutTime, u.IsLogout, u.DeviceInfo)
}
